package com.tourism.controller;

import com.github.pagehelper.PageInfo;
import com.tourism.entity.CustomLine;
import com.tourism.entity.CustomLineQuery;
import com.tourism.entity.Line;
import com.tourism.exception.GlobalException;
import com.tourism.service.CustomLineService;
import com.tourism.util.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 定制线路相关的控制器
 * @Author z
 * @Date 2021-03-01 20:40
 */
@Controller
@RequestMapping("/customLine")
public class CustomLineController {


    @Autowired
    private CustomLineService customLineService;

    /**
     * 根据定制线路id查询定制线路信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getCustomLineById")
    @ResponseBody
    public CustomLine getCustomLineById(Long id) {
        return customLineService.getCustomLineById(id);
    }

    /**
     * 删除线路定制
     *
     * @param id
     * @return
     */

    @DeleteMapping("/deleteCustomLineById")
    @ResponseBody
    public Response deleteCustomLineById(Long id) {
        return Response.success(customLineService.deleteCustomLineById(id));

    }
    /**
     * 新增定制线路
     *
     * @param customLine
     * @return
     */
    @PostMapping("/addCustomLine")
    @ResponseBody
    public Response addCustomLine(@RequestBody CustomLine customLine) {
        return Response.success(customLineService.addCustomLine(customLine));

    }
    /**
     * 修改线路定制
     *
     * @param customLine
     * @return
     */
    @PostMapping("/updateCustomLine")
    @ResponseBody
    public Response updateCustomLine(@RequestBody CustomLine customLine) {
        return Response.success(customLineService.updateCustomLine(customLine));

    }

    /**
     * 更新定制线路得受理状态
     *
     * @param accept
     * @param id
     * @return
     */
    @PostMapping("/updateCustomLineAccept")
    @ResponseBody
    public boolean updateCustomLineAccept(Long id, boolean accept) throws GlobalException {
        return customLineService.updateCustomLineAccept(id, accept);
    }

    /**
     * 查询定制线路列表
     *
     * @param customLineQuery
     * @return
     */
    @PostMapping("/getCustomLineList")
    @ResponseBody
    public PageInfo<CustomLine> getCustomLineList(@RequestBody CustomLineQuery customLineQuery) {
        return customLineService.getCustomLineList(customLineQuery);
    }

}
